package scala.examples.tcpoly.parsing

trait StringParsers extends Parsers {
  type Input = String
  type Elem = Char
  private val EOI = 0.toChar

  abstract class X(self: Input) extends ParseInput {
  	def result[T](r: T): Success[T] = Success(r, self)(Failure("zero", self))
    def failure: Failure = Failure("unknown failure", self)
    def error: Error = Error("unknown error", self)
  }
  
  implicit def InputIsParseInput(self: Input) = new X(self) {
  	def first: Elem = if(self == "") EOI else self(0)
  	def rest: Input = if(self == "") self else self.substring(1)
	}
  
  def eoi = accept(EOI)
}